/*
 * Copyright (C) 2010 Juan José Ortilles jortilles@gmail.com
 *
 * This program is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU General Public License as published by the Free 
 * Software Foundation; either version 3 of the License, or 
 * any later version.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * 
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along 
 * with this program; if not, write to the Free Software Foundation, Inc., 
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
 *
 */

package net.juantxu.pentaho.launcher.utilidades;

import java.io.*;
import java.util.*;

import org.apache.log4j.Logger;

public class EscribeProperties{
	static Logger log = Logger.getLogger(EscribeProperties.class);

	public  EscribeProperties(String propiedad, String valor){
		try{	
            int check=0;
            while(check == 0){
				check=1;
				Properties pro = new Properties();
				File f = new File("pentahoLauncher.properties");
				if(!f.exists()){
					check=0;
					log.error("pentahoLauncher.properties no existe");
				}
				else{
					FileInputStream in = new FileInputStream(f);
					pro.load(in);
					pro.setProperty(propiedad, valor);
					pro.store(new FileOutputStream("pentahoLauncher.properties"),null);
					log.info("pentahoLauncher.properties actualizado correctamente");
				}
			}
		}
		catch(IOException e){
		System.out.println(e.getMessage());
		}
	}
	
}